# -*- coding: utf-8 -*-

# File Name : __init__.py
# Description :
# Author : marje
# date : 2022/6/5
# Change Activity : 2022/6/5
from .image_io import ReadImage, WriteImage
from .img_loader import LoadImage
from .normalize import Normalize
from .resize import ResizeImg
from .show_img import ShowImg
from .tensor_to_numpy import TensorToNumpy
from ... import REGISTER_FACTORY

_REGISTRY_NAME = 'cv_modules'


def _build_registry():
    """
    build registry.

    """
    _register = REGISTER_FACTORY.create_registry(_REGISTRY_NAME)
    _register.add('ReadImage', value=ReadImage)
    _register.add('WriteImage', value=WriteImage)
    _register.add('LoadImage', value=LoadImage)
    _register.add('Normalize', value=Normalize)
    _register.add('ResizeImg', value=ResizeImg)
    _register.add('ShowImg', value=ShowImg)
    _register.add('TensorToNumpy', value=TensorToNumpy)


_build_registry()  # build when module load.


def build_cv_modules(cfg=None, name=None):
    """
    build norm layer

    Args:
        name: module name
        cfg: must contain num_features;

    Returns:

    """
    return REGISTER_FACTORY.build_from_config(_REGISTRY_NAME, cfg, name)


def load_cv_module_registry():
    """
    init dl module.

    """
    return REGISTER_FACTORY.get_register(_REGISTRY_NAME)
